package com.xiong.date;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.Period;
import java.time.format.DateTimeFormatter;
import java.time.format.TextStyle;
import java.util.Locale;

public class DateIterator {

    public static void main(String[] args) {

        LocalDate startDate = LocalDate.of(2022, 5, 6);  // 设置开始日期
        LocalDate endDate = LocalDate.now();  // 获取当前日期

        Period period = Period.between(startDate, endDate);  // 获取日期间隔

        LocalDate currentDate = startDate;

        System.out.println("日期列表：");
        while (currentDate.isBefore(endDate) || currentDate.isEqual(endDate)) {
            DayOfWeek dayOfWeek=currentDate.getDayOfWeek();
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEEE", Locale.CHINESE);
            String dayOfWeekChinese = dayOfWeek.getDisplayName(TextStyle.FULL, Locale.CHINESE);

            System.out.println(currentDate+" "+dayOfWeekChinese+" "+dayOfWeek.name());

            System.out.println(dayOfWeek.name());
            currentDate = currentDate.plusDays(1);  // 增加一天
        }

    }


}
